const fs = require('fs');
const path = require('path');
const JSON5 = require('json5');
// const Mock = require('mockjs');
const Vue  = require('vue');

// function getJson5File(filePath) {
//   var jsonData = fs.readFileSync(path.join(__dirname, './test.json5'), 'utf-8');
//   return JSON5.parse(jsonData);
// }

// import fs from "fs"
// import path from "path"
// import JSON5 from "json5"
// import Mock from "mockjs"
// import Test from "./Test/index"

// const UserTest = require('./Test/UserTest');
// console.log(UserTest);
// console.log(typeof UserTest);

const Test = require('./Test/index');
const mockArr = [
  ...Test
]
// console.log(mockArr);

// export default function (app) {
module.exports = function (app) {
  console.log();
  console.log("process.env.NODE_ENV");
  console.log(process.env.NODE_ENV);
  console.log("process.env.VUE_APP_API_URL");
  console.log(process.env.VUE_APP_API_URL);

  // console.log(app);
  // console.log(typeof app);
  // console.log(app instanceof Vue);// false
  // console.log(app === Vue);// false
  console.log("/src/mock/index.js", process.env.VUE_APP_MOCK);
  console.log("/src/mock/index.js", typeof process.env.VUE_APP_MOCK);
  if (process.env.VUE_APP_MOCK == "true") {
    // 监听请求
    
    // app.get("/mock/user/userInfo", function (req, res) {
    //   res.json({ custom: 'response' });
    // });

    // app.get("/mock/user/userInfo", function (req, res) {
    //   var jsonObj = getJson5File('./test.json5');
    //   res.json(Mock.mock(jsonObj));
    //   // res.json({ custom: 'response' });
    // });

    // UserTest(app)

    mockArr.forEach((fn) => {
      fn(app)
    })
  }
}
